<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>表单</title>
    <link rel="stylesheet" href="../frame/layui/css/layui.css">
    <link rel="stylesheet" href="../frame/static/css/style.css">
    <link rel="icon" href="../frame/static/image/code.png">
</head>
<body class="body">


<blockquote class="layui-elem-quote layui-text">
    这里放公告
</blockquote>

<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
    <legend>添加销售记录</legend>
</fieldset>

<form class="layui-form" action="">

    <div class="layui-form-item">
        <label class="layui-form-label">商品名称</label>
        <div class="layui-input-inline">
            <select name="modules" lay-verify="required" lay-search="">
                <option value="">直接选择或搜索选择</option>
                <option value="1">广胜电缆</option>
                <option value="2">瑞奇电锤</option>

            </select>
            <div class="layui-unselect layui-form-select layui-form-selected">
                <div class="layui-select-title"><input placeholder="直接选择或搜索选择" value="" class="layui-input layui-unselect" type="text">
                    <i class="layui-edge"></i>
                </div>
                <dl class="layui-anim layui-anim-upbit" style="">
                    <dd lay-value="" class="layui-select-tips">直接选择或搜索选择</dd>
                    <dd lay-value="1" class="">广胜电缆</dd>
                    <dd lay-value="2" class="">广胜电缆</dd>
                </dl>
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">商品规格</label>
        <div class="layui-input-inline">
            <select name="modules" lay-verify="required" lay-search="">
                <option value="">直接选择或搜索选择</option>
                <option value="1">1.5</option>
                <option value="2">2.5</option>
            </select>
            <div class="layui-unselect layui-form-select layui-form-selected">
                <div class="layui-select-title"><input placeholder="直接选择或搜索选择" value="" class="layui-input layui-unselect" type="text">
                    <i class="layui-edge"></i>
                </div>
                <dl class="layui-anim layui-anim-upbit" style="">
                    <dd lay-value="" class="layui-select-tips">直接选择或搜索选择</dd>
                    <dd lay-value="1" class="">1.5</dd>
                    <dd lay-value="2" class="">2.5</dd>
                </dl>
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">客户名</label>
            <div class="layui-input-inline" >
                <input type="text" name="price_min" placeholder="请输入客户名" lay-verify="required|number" autocomplete="off" class="layui-input">
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">数量</label>
            <div class="layui-input-inline">
                <input type="text" name="number" lay-verify="number" autocomplete="off" placeholder="请输入数量" class="layui-input">
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">售出价格</label>
        <div class="layui-input-inline">
            <input type="text" name="price_min" placeholder="￥" lay-verify="required|number" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">售出时间</label>
            <div class="layui-input-inline">
                <input name="date" id="date" lay-verify="date" placeholder="yyyy-MM-dd" autocomplete="off" class="layui-input" lay-key="1" type="text">
            </div>
            <div class="layui-form-mid layui-word-aux"></div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">付款时间</label>
            <div class="layui-input-inline">
                <input name="date" id="date" lay-verify="date" placeholder="yyyy-MM-dd" autocomplete="off" class="layui-input" lay-key="1" type="text">
            </div>
            <div class="layui-form-mid layui-word-aux"></div>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label"></label>
        <button class="layui-btn" lay-submit="" lay-filter="demo2">保存</button>
        <button class="layui-btn"   lay-filter="demo2" onclick="window.history.back(-1)">返回</button>
    </div>

</form>

<script src="../frame/layui/layui.js" charset="utf-8"></script>
<script>
    layui.use(['form', 'layedit', 'laydate'], function(){
        var form = layui.form
            ,layer = layui.layer
            ,layedit = layui.layedit
            ,laydate = layui.laydate;

        //日期
        laydate.render({
            elem: '#date'
        });
        laydate.render({
            elem: '#date1'
        });

        //创建一个编辑器
        var editIndex = layedit.build('LAY_demo_editor');

        //自定义验证规则
        commodity_add.verify({
            title: function(value){
                if(value.length < 5){
                    return '标题至少得5个字符啊';
                }
            }
            ,pass: [/(.+){6,12}$/, '密码必须6到12位']
            ,content: function(value){
                layedit.sync(editIndex);
            }
        });

        //监听指定开关
        commodity_add.on('switch(switchTest)', function(data){
            layer.msg('开关checked：'+ (this.checked ? 'true' : 'false'), {
                offset: '6px'
            });
            layer.tips('温馨提示：请注意开关状态的文字可以随意定义，而不仅仅是ON|OFF', data.othis)
        });

        //监听提交
        commodity_add.on('submit(demo1)', function(data){
            layer.alert(JSON.stringify(data.field), {
                title: '最终的提交信息'
            });
            return false;
        });


    });
    layui.use('upload', function() {
        var $ = layui.jquery
            , upload = layui.upload;

        //普通图片上传
        var uploadInst = upload.render({
            elem: '#demo1'
            , url: '/upload/'
            , before: function (obj) {
                //预读本地文件示例，不支持ie8
                obj.preview(function (index, file, result) {
                    $('#demo1').attr('src', result); //图片链接（base64）
                });
            }
            , done: function (res) {
                //如果上传失败
                if (res.code > 0) {
                    return layer.msg('上传失败');
                }
                //上传成功
            }
            , error: function () {
                // //演示失败状态，并实现重传
                // var demoText = $('#demoText');
                // demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
                // demoText.find('.demo-reload').on('click', function () {
                //     uploadInst.upload();
                // });
            }
        });
    });
</script>
</body>
</html>